package sctu.edu.java.year2016.team06.chenqiang.day20160606.chapter12_2;

import java.io.*;

/**
 * Created by XQ on 2016/6/6.
 * 编写程序，使用字符输入输出流读取文件，将一段文字加密后传入文件，并将加密前和加密后的文件输出
 */
public class Encryption {
    public static void main(String[] args) {
        String s="今天是星期一";
        char[] charArry=s.toCharArray();
        StringBuffer builder=new StringBuffer();
        for(char c:charArry){
            builder.append((int)c+"");
        }
        File file=new File("D:\\Student.txt");
        try {
            file.createNewFile();
            DataOutputStream dataOutputStream=new DataOutputStream( new FileOutputStream(file));
            DataInputStream dataInputStream = new DataInputStream(new FileInputStream(file));
            dataOutputStream.write(builder.toString().getBytes());
            dataOutputStream.close();
            dataInputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
